package com.ddwl.common.feign.api;

import com.ddwl.schema.bo.wallet.*;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.dist.DistVo;
import com.ddwl.schema.vo.wallet.AgentDistStatisticsDto;
import com.ddwl.schema.vo.wallet.UserCouponVo;
import com.ddwl.schema.vo.wallet.UserSubsidyVo;
import com.ddwl.schema.vo.wallet.WithdrawChannelVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * 类walletApi.java的实现描述：TODO
 *
 * @author zach
 * @Date :2020-07-30 10:30.
 */

@FeignClient(name = "ddwl-wallet", path = "/wallet")
public interface WalletApi {

    /**
     * 获取用户津贴
     *
     * @param userId
     * @return
     */
    @GetMapping("/subsidy/{userId}/get")
    RestVo<UserSubsidyVo> getSubsidy(@PathVariable String userId, @RequestParam("product") String product);

    /**
     * 发放津贴
     *
     * @param bo
     * @return
     */
    @PostMapping("/subsidy/provideSubsidy")
    RestVo provideSubsidy(@RequestBody ProvideSubsidyBo bo);

    /**
     * 获取订单分销
     *
     * @param orderId
     * @return
     */
    @GetMapping("/dist/order/getDist/{orderId}")
    RestVo<List<DistVo>> getDistOrder(@PathVariable String orderId);


    /**
     * 售后分销订单
     *
     * @param orderId
     * @return
     */
    @PostMapping("/dist/order/returnDistOrder/{orderId}")
    RestVo returnDistOrder(@PathVariable String orderId, @RequestParam("spuId") String spuId, @RequestParam("refundAmount") BigDecimal refundAmount, @RequestParam("refundId") String refundId);

    /**
     * 订单抵扣津贴
     *
     * @param bo
     * @return
     */
    @PostMapping("/subsidy/deductedSubsidy")
    RestVo deductedSubsidy(@RequestBody DeductedSubsidyBo bo);

    /**
     * 订正分销用户钱包信息
     *
     * @param userId
     * @param fxUserId
     * @return
     */
    @PostMapping("/user/correctWalletInfo")
    RestVo correctWalletInfo(@RequestParam("fxUserId") String fxUserId, @RequestParam("userId") String userId);

    @PostMapping("/Withdraw/queryWithdrawRecordList")
    @ApiOperation("管理后台查询提现记录数量")
    RestVo<Integer> queryWithdrawRecordCount(@RequestBody WithdrawListQueryBo bo);

    @ApiOperation(value = "门店新增提现渠道")
    @PostMapping("/WithdrawChannel/fenxiaoChannel")
    RestVo fenxiaoWithdrawChannel(@Valid @RequestBody WithdrawChannelAddBo bo);

    @ApiOperation(value = "查询用户银行卡信息")
    @GetMapping("/WithdrawChannel/getUserBankCard/{bankNumber}")
    RestVo<WithdrawChannelVo> getUserBankCard(@PathVariable("bankNumber") String bankNumber);

    @ApiOperation(value = "获取用户账户金额")
    @GetMapping("/user/amount/list")
    RestVo<Map<String, BigDecimal>> queryUserWalletList(@RequestBody List<String> userIds);


    /**
     * 提交退款接口
     * 提交退款申请时调用
     * 步骤1.创建分销退款订单
     * 步骤2。对分销订单进行标记售后，退款次数的叠加
     *
     * @param orderId      必填
     * @param spuId        非必填
     * @param refundAmount 必填
     * @param refundId     必填
     */
    @PostMapping("/dist/order/refund/cre")
    RestVo createOrderRefundAmount(@RequestParam String orderId, @RequestParam String spuId, @RequestParam BigDecimal refundAmount, @RequestParam String refundId, @RequestParam Integer skuQty);


    /**
     * 提交退款 锁定退款金额
     * 注意：在调用支付渠道退款前调用
     * 步骤1.判断是否生成退款单如果没有生成创建退款单
     * 步骤2.如果是店铺订单锁定店铺退款金额
     *
     * @param orderId      必填
     * @param spuId        非必填
     * @param refundAmount 必填
     * @param refundId     必填
     */
    @PostMapping("/dist/order/refund/submit")
    RestVo submitOrderRefund(@RequestParam String orderId, @RequestParam String spuId, @RequestParam BigDecimal refundAmount, @RequestParam String refundId, @RequestParam Integer skuQty);

    /**
     * 取消退款
     * 注意:在取消或者关闭售后单的时候调用
     * 步骤1.对分销订单退款次数递减
     * 步骤2.如果是店铺订单释放佣金
     * 步骤3.更新订单退款状态
     *
     * @param refundId
     */
    @PostMapping("/dist/order/refund/cancel")
    RestVo cancleOrderRefund(@RequestParam String refundId);


    /**
     * 完成退款接口
     * 更新退款订单状态
     *
     * @param refundId
     */
    @PostMapping("/dist/order/refund/complete")
    RestVo finishOrderRefund(@RequestParam String refundId);

    /**
     * 用户钱包变更
     *
     * @param changeRecord
     * @param userId
     * @param walletFlowType
     * @param amount
     * @return
     */
    @GetMapping("/user/changeWallet")
    RestVo changeWallet(@RequestParam String changeRecord, @RequestParam String userId, @RequestParam Integer walletFlowType, @RequestParam BigDecimal amount);

    /**
     * 查看用户优惠券
     *
     * @param userCouponIds
     * @return
     */
    @PostMapping("/coupon/user/info")
    RestVo<List<UserCouponVo>> userCoupons(@RequestBody List<String> userCouponIds);

    /**
     *
     * @param userCouponId
     * @return
     */
    @PostMapping("/coupon/user/check")
    RestVo checkCoupon(@RequestParam String userCouponId,@RequestParam Boolean use);

    /**
     *
     * @param distUserId
     * @param sources
     * @return
     */
    @GetMapping("/dist/order/agentDistStatistics")
    RestVo<List<AgentDistStatisticsDto>> getAgentDistStatistics(@RequestParam String distUserId, @RequestParam List<String> sources);

    /**
     * 发放优惠券
     * @param list
     * @return
     */
    @PostMapping("/coupon/user/issue")
    RestVo issueCoupon(@RequestBody List<IssueCouponBo> list);

}